package com.bytezero.dropdownlist;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

import androidx.annotation.NonNull;




public class HomeDialog extends Dialog {
    private static final String TAG = "HomeDialog";

    private Button mBtnOk;
    private Button mBtnCancel;
    Context mContext;

    public HomeDialog(@NonNull Context context) {
        super(context, R.style.MyDialog);
        mContext = context;
        initview(context);
    }

    private void initview(Context context) {
        View view = ((Activity) context).getLayoutInflater().inflate(R.layout.home_dialog, null);
        setCanceledOnTouchOutside(true);
        WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
        //layoutParams.width = DisplayUtil.getScreenWidth((Activity) context) - 100;
        // layoutParams.height = DisplayUtil.getScreenHeight((Activity) context) - 50;

        Window window = HomeDialog.this.getWindow();
            //设置弹出位置
        window.setGravity(Gravity.TOP | Gravity.CENTER);

        layoutParams.gravity = Gravity.TOP;
        layoutParams.alpha = 0.9f;
        setContentView(view, layoutParams);
        findViews();
    }

    private void findViews() {
        mBtnOk = (Button) findViewById(R.id.btn_ok);
        mBtnCancel = (Button) findViewById(R.id.btn_cancel);
        mBtnOk.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                // mContext.startActivity(new Intent(mContext,LoginActivity.class));
                dismiss();
                //ActivityManager.getInstance().finishAllActivities(LoginActivity.class);
            }
        });
        mBtnCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

    }

}
